<?php

namespace app\shop\controller\examination;

use app\shop\model\examination\ExaminationAward as examinationModel;
use app\shop\model\hire\Category as CategoryModel;
use app\shop\controller\Controller;

/**
 * 简历管理控制器
 */
class Award extends Controller
{
    /**
     * 简历列表(全部)
     */
    public function index()
    {
        // 获取全部列表
        $model = new examinationModel;
        $data = $this->postData();
        $list = $model->getList($data);
        return $this->renderSuccess('', compact('list'));
    }


    /**
     * 添加
     */
    public function add()
    {
        // get请求
        if ($this->request->isGet()) {


            return $this->renderSuccess('');
        }
        //post请求
        $model = new examinationModel;
        if ($model->add($this->postData())) {
            return $this->renderSuccess('添加成功');
        }
        return $this->renderError($model->getError() ?: '添加失败');
    }

    /**
     * 编辑
     */
    public function edit($id)
    {
        $model = new examinationModel;
        $model =$model::detail($id);
        if ($this->request->isGet()) {

            return $this->renderSuccess('', compact('model'));
        }
        // 更新记录
        if ($model->edit($this->postData())) {
            return $this->renderSuccess('更新成功');
        }
        return $this->renderError($model->getError() ?: '更新失败');
    }





    /**
     * 删除
     */
    public function delete($id)
    {
        // 详情
        $model = examinationModel::detail($id);
        if (!$model->setDelete()) {
            return $this->renderError($model->getError() ?: '删除失败');
        }
        return $this->renderSuccess('删除成功');
    }

}
